package com.gagakuai.bpm.config.schleTask;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executors;

/*
 * @program: bpm_server
 * @description: 定时任务并发配置
 * @author: houhong
 * @create: 2022-06-28 10:07
 */
@Configuration
public class SchedulingConfig implements SchedulingConfigurer {

    @Value("${schduing.num}")
    private Integer scheduleNumber;


    @Override
    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
        //设定一个长度10的定时任务线程池
        scheduledTaskRegistrar.setScheduler(Executors.newScheduledThreadPool(scheduleNumber));
    }
}